//
//  SAPayInstructionsVC.m
//  saasRetail
//
//  Created by 黄志刚 on 2021/8/19.
//

#import "SAPayInstructionsVC.h"
#import "YBImageBrowser.h"

@interface SAPayInstructionsVC ()<UITableViewDelegate, UITableViewDataSource, YBImageBrowserDataSource>

@property (nonatomic, strong) UITableView *tableView;

@end

@implementation SAPayInstructionsVC

- (void)viewDidLoad {
    [super viewDidLoad];
    
}

#pragma mark - initUI
-(void)initUI {
    [self setNavigationItemBackBBIAndTitle:@"操作说明"];
    [self setBgImage:nil];
    self.view.backgroundColor = kColor(239, 241, 243, 1);
    [self.view addSubview:self.tableView];
    UIImageView *imageV = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"pay_instructions"]];
    imageV.frame = SARectMake(0, StatusHeight, 375, 1633);
    imageV.userInteractionEnabled = YES;
    UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(clickedTap)];
    [imageV addGestureRecognizer:tap];
    self.tableView.tableHeaderView = imageV;
}

#pragma mark - UITableView Delegate & DataSource
-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
    return 0;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return 0;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    return nil;
}

-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    
}

-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
    return kScaleNum(10);
}

- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section {
    return [[UIView alloc] initWithFrame:CGRectZero];
}

- (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section {
    return [[UIView alloc] initWithFrame:CGRectZero];
}

-(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section {
    return kScaleNum(0.01);
}

-(CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section {
    return kScaleNum(0.01);
}

-(void)clickedTap {
    YBImageBrowser *browser = [YBImageBrowser new];
    browser.dataSource = self;
    browser.currentPage = 0;
    [browser show];
}

//YBImageBrowserDataSource 代理实现赋值数据
- (NSInteger)yb_numberOfCellsInImageBrowser:(YBImageBrowser *)imageBrowser {
    return 1;
}

- (id<YBIBDataProtocol>)yb_imageBrowser:(YBImageBrowser *)imageBrowser dataForCellAtIndex:(NSInteger)index {
//    NSString *urlStr = [self.imageList objectAtIndex:index];
    YBIBImageData *data = [YBIBImageData new];
    data.defaultLayout.horizontalFillType = YBIBImageFillTypeFullWidth;
    data.defaultLayout.verticalFillType = YBIBImageFillTypeFullWidth;
    data.imageName = @"pay_instructions";
    return data;
}

-(UITableView *)tableView {
    if (!_tableView) {
        _tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, kScaleNum(StatusHeight), kScreenWidth, kScreenHeight - kScaleNum(StatusHeight) - SafeFooterHeight) style:UITableViewStyleGrouped];
        _tableView.backgroundColor = kColor(239, 241, 243, 1);
        _tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
        _tableView.delegate = self;
        _tableView.dataSource = self;
        _tableView.showsHorizontalScrollIndicator = NO;
        if (@available(iOS 11.0, *)) {
            _tableView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
        }else {
            self.automaticallyAdjustsScrollViewInsets = NO;
        }
        _tableView.estimatedRowHeight = 0;
        _tableView.estimatedSectionHeaderHeight = 0;
        _tableView.estimatedSectionFooterHeight = 0;
    }
    return _tableView;
}

@end
